<?php
namespace app\index\controller;


use app\common\controller\Base;
use app\common\model\Temp as TempModel;
use app\common\model\TempCate;
use app\common\model\TempColor;
use think\facade\Request;

class Temp extends Base
{
    /*
     * 模板列表
     */
    public function tempList(TempCate $tempCate, TempColor $tempColor, TempModel $tempModel)
    {
        $cateList = $tempCate->getInfoList();

        if ($cateList) {
            $this->assign('cateList',$cateList);
        }

        $colorList = $tempColor->getInfoList();

        if ($colorList) {
            $this->assign('colorList',$colorList);
        }

//        dump(Request::param());

        $map = [];

        if (Request::param('cate_id')) {
            $map[] = ['cate_id','=',Request::param('cate_id')];
        }

        if (Request::param('type_id')) {
            $map[] = ['type_id','=',Request::param('type_id')];
        }

        if (Request::param('color_id')) {
            $map['color_id'] = ['color_id','=',Request::param('color_id')];
        }

        $datas = $tempModel->getPageList($map,10);

        $this->assign('datas',$datas);
        $this->assign('title','网站模板');
        return $this->fetch('tempList');
    }

}